-
-
Notifications
You must be signed in to change notification settings - Fork 379
Feature: add bun.js runtime [WIP] #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I'd love bun support! I haven't tested your PR yet, but have you tried removing the '&' from Line 104 in e403fda
|
|
Yes i have, the command at first was running without & and had the same problem. I have added it to try and solve the problem but didn't work. |
|
Just found the problem. The Installation of bun when running their script what should we do ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for Bun.js as a new runtime option for deploying JavaScript/TypeScript applications, following the same architectural patterns as the existing Node.js integration. The implementation includes service installation/uninstallation, site type registration, deployment scripts, and supervisor worker management. However, there are critical issues preventing workers from starting correctly, which aligns with the problem described in the PR description.
Key changes:
- Adds Bun service handler for installing/uninstalling Bun runtime versions
- Implements Bun site type for deploying Bun applications with git integration
- Registers Bun in service and site type providers with version management
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
resources/views/ssh/services/bun/uninstall-bun.blade.php |
Shell script to remove Bun installation and clean up configuration files |
resources/views/ssh/services/bun/install-bun.blade.php |
Shell script to install specific Bun versions via official installer |
resources/deployment-scripts/bun.sh |
Deployment script for pulling code, installing dependencies, building, and restarting services |
app/WorkflowActions/Site/CreateBunSite.php |
Workflow action defining inputs for creating Bun sites via API |
app/SiteTypes/Bun.php |
Core site type handler implementing installation, vhost configuration, and base commands |
app/Services/Bun/Bun.php |
Service handler managing Bun runtime installation, uninstallation, and version detection |
app/Providers/SiteTypeServiceProvider.php |
Registers Bun site type with form fields for source control, port, repository, and branch |
app/Providers/ServiceTypeServiceProvider.php |
Registers Bun service type with supported versions |
app/Models/Server.php |
Adds methods to query installed Bun versions and retrieve Bun service instances |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/SiteTypes/Bun.php
Outdated
| $this->site->server->ssh()->exec( | ||
| __('bun --cwd :path install', [ | ||
| 'path' => $this->site->path, | ||
| ]), | ||
| 'install-bun-dependencies', | ||
| $this->site->id | ||
| ); | ||
| $this->site->server->ssh()->exec( |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSH commands are not being executed with the site user context. The NodeJS site type passes the user to ssh() like $this->site->server->ssh($this->site->user)->exec(...) to ensure commands run as the correct isolated user. Without this, the commands will run as the default SSH user, which can cause permission issues and defeats the isolation mechanism. The same issue exists on lines 96-102.
| $this->site->server->ssh()->exec( | |
| __('bun --cwd :path install', [ | |
| 'path' => $this->site->path, | |
| ]), | |
| 'install-bun-dependencies', | |
| $this->site->id | |
| ); | |
| $this->site->server->ssh()->exec( | |
| $this->site->server->ssh($this->site->user)->exec( | |
| __('bun --cwd :path install', [ | |
| 'path' => $this->site->path, | |
| ]), | |
| 'install-bun-dependencies', | |
| $this->site->id | |
| ); | |
| $this->site->server->ssh($this->site->user)->exec( |
| __('bun --bun run --cwd :path build', [ | ||
| 'path' => $this->site->path, | ||
| ]), | ||
| 'bun-build', | ||
| $this->site->id | ||
| ); | ||
| $this->progress(65); | ||
| $command = __('bun --bun run --cwd :path start', [ |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --bun flag is typically unnecessary for modern Bun versions and may cause compatibility issues. Bun automatically uses its own runtime by default. Consider simplifying the commands to bun run build and bun run start unless there's a specific reason to force the Bun runtime (e.g., when Node compatibility mode might otherwise be triggered). This would also make the commands more consistent with the install command which doesn't use --bun.
| __('bun --bun run --cwd :path build', [ | |
| 'path' => $this->site->path, | |
| ]), | |
| 'bun-build', | |
| $this->site->id | |
| ); | |
| $this->progress(65); | |
| $command = __('bun --bun run --cwd :path start', [ | |
| __('bun run --cwd :path build', [ | |
| 'path' => $this->site->path, | |
| ]), | |
| 'bun-build', | |
| $this->site->id | |
| ); | |
| $this->progress(65); | |
| $command = __('bun run --cwd :path start', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the --bun flag is necessary as stated by the bun team because it forces bun to use itself instead of Nodejs for serving the application, this is especially true for Nextjs.
| # Verify installation | ||
| bun --version |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PATH exports are only effective within the current shell session and won't persist. The Bun installer (line 5) already handles adding Bun to shell configuration files. The exports on lines 8-9 are redundant and won't affect the verification command on line 12 unless they're in the same script context. To properly verify the installation, use the full path: $HOME/.bun/bin/bun --version instead of relying on the PATH exports.
| # Verify installation | |
| bun --version | |
| # Verify installation using absolute path to avoid PATH issues | |
| "$HOME/.bun/bin/bun" --version |
|
|
||
| bun install | ||
|
|
||
| bun --bun run build |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deployment script uses --bun flag inconsistently. Line 7 uses bun --bun run build while line 5 uses just bun install. For consistency and to avoid potential compatibility issues, either use the --bun flag for all commands or remove it entirely. Modern Bun versions don't require the --bun flag as they use their own runtime by default.
| bun --bun run build | |
| bun run build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it is consistent, bun install is a particular command it does not need the --bun flag but the other commands like run dev, run build and run start need the --bun flag.
app/Services/Bun/Bun.php
Outdated
| return trim($version); | ||
| } | ||
| } | ||
|
|
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line at end of file. The file should end with a single newline after the closing brace, not two blank lines. This is inconsistent with other service files like NodeJS.php.
| $command = __('bun --bun run --cwd :path start', [ | ||
| 'path' => $this->site->path, | ||
| ]); |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The worker command uses bun without the full path, but Bun is installed to $HOME/.bun/bin/bun which is not in supervisor's PATH. Unlike NodeJS which is installed system-wide via apt to /usr/bin/npm, Bun is installed per-user. Supervisor doesn't source shell configs where the Bun PATH is added. This is the root cause of workers getting stuck in "starting" state - supervisor cannot find the bun executable. The command should be changed to use the full path like /home/{user}/.bun/bin/bun --bun run --cwd :path start, where {user} is the site user. Alternatively, set the PATH environment variable in the supervisor config or install Bun system-wide.
| BUN_VERSION={{ $version }} | ||
|
|
||
| # Install Bun using the official installer | ||
| curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The install-bun script downloads and executes remote code from https://bun.sh/install via curl | bash without any integrity verification or pinning. If the Bun installer endpoint or its TLS chain is compromised, this would let an attacker run arbitrary commands on every server where this installer is invoked. Consider installing Bun via a package manager or a locally stored, checksum-verified artifact, or at minimum verify the script’s integrity and pin to a specific, trusted version before executing it.
…t after it because it is different than `bun run dev`, `bun run build` ...etc
…al/bin instead of per user and clean up PATH entries.
|
I have just changed the installation to become global added # Move Bun binary to /usr/local/bin for global access
sudo mv ~/.bun/bin/bun /usr/local/bin/
sudo chmod a+x /usr/local/bin/bun
# The installation script adds "~/.bun/bin" to $PATH in "~/.bashrc" automatically, we should remove it
sed -i '/\.bun\/bin/d' "$HOME/.bashrc" 2>/dev/null || true
sed -i '/\.bun\/bin/d' "$HOME/.zshrc" 2>/dev/null || trueand the bun worker works well now! |
|
Installation still errors in bun install v1.3.4 (5eb2145b)
EACCES: Permission denied: could not create the "node_modules" directory (mkdir) |
|
My bad I was using $this->site->server->ssh()->exec(...) to execute the install and build for bun dependencies, i had to use $this->site->server->ssh($this->site->user)->exec(...) to scope the execution to the isolated user. 🤦♂️ Now everything works well, just like with NodeJS. |
c4faf34 to
220cb50
Compare
|
Since this is a plugin now, shall we close the PR? |
|
Yes of course, Thank you so much @saeedvaziry . |

[WIP]
One of the most hot runtimes nowadays is bun, it is fast, reliable and for me i really need it my projects.
I have tried integrating it with vitodeploy and it works. But I am stuck in one problem I could not solve yet, which has to do with starting, pausing, and restarting the worker that launches the bun start script.
when i start it it stays in starting state, when i pause it same, and when i restart it it fails.
I would love to have some help from the interested folks here !
Thanks in advance ❤️